Efficient use of memory and accessing of stored records

ABSTRACT

Memory is used, including by receiving at a processor an indication that a first piece of metadata associated with a set of backup data is required during a block based backup and/or restore. The processor is used to retrieve from a metadata store a set of metadata that includes the first piece of metadata and one or more additional pieces of metadata included in the metadata store in an adjacent location that is adjacent to a first location in which the first piece of metadata is stored in the metadata store, without first determining whether the one or more additional pieces of metadata are currently required. The retrieved set of metadata is stored in a cache.

CROSS REFERENCE TO OTHER APPLICATIONS

This application is a divisional of co-pending U.S. patent applicationSer. No. 11/473,485 entitled EFFICIENT USE OF MEMORY AND ACCESSING OFSTORED RECORDS filed Jun. 23, 2006 now U.S. Pat. No. 7,694,103 which isincorporated herein by reference for all purposes.

BACKGROUND OF THE INVENTION

In some block based backup systems, files or other data objects arebacked up by storing blocks associated with the data objects beingbacked up. Blocks and associated metadata are updated as needed and areretrieved in the event a file or other data object is restored. Duringrestoration, blocks and other information (e.g., an inode numberassociated with files being restored and/or physical locations of blocksassociated with those files) are retrieved from backup media or othermemory. For example, for each file to be restored in some systems a filename is mapped to an inode number, the inode number is used to identifyblocks comprising the file and the location at which each block isstored on backup media, the blocks comprising the file are read from thebackup media, and the blocks read from backup media are used to restorethe file to the destination machine. Throughout a restoration process, avariety of information is stored in memory by various processes oragents running on the components of a block based backup system. Readingand/or writing information to memory may contribute to the amount oftime a restoration requires. Some block based systems take hours toperform a restore, for example when restoring a large directorycontaining a million or more files. Reducing the amount of time toread/write to memory would be desirable, since this may reduce theoverall amount of time required to perform a restoration.

BRIEF DESCRIPTION OF THE DRAWINGS

Various embodiments of the invention are disclosed in the followingdetailed description and the accompanying drawings.

FIG. 1 is a system diagram illustrating an embodiment of a backupsystem.

FIG. 2A is a diagram illustrating an embodiment of a metadata tableassociated with block based backup.

FIG. 2B is a diagram illustrating an embodiment of blocks retrieved froma backup storage device and forwarded to a restoration target.

FIG. 3 is a flowchart illustrating an embodiment of a process performedby a backup server to restore one or more files on a restoration target.

FIG. 4 is a flowchart illustrating an embodiment of a process performedby a client or agent running on a restoration target to restore one ormore files on the restoration target.

FIG. 5A is a diagram illustrating an embodiment of a memory that isobtained, written to, read from, or otherwise used in an efficientmanner.

FIG. 5B is a diagram illustrating an embodiment of a tracking table usedto track usage of a block of memory.

FIG. 6A is a flowchart illustrating an embodiment of a process forobtaining memory from a memory allocator and sub-allocating a locationin the memory to a backup and/or restoration task.

FIG. 6B is a flowchart illustrating an embodiment of a process forobtaining memory from a memory allocator and sub-allocating a locationin the memory to a subsequent backup and/or restoration task, if any,once the location become available.

FIG. 7 is a flowchart illustrating an embodiment of a process forobtaining memory.

FIG. 8 is a flowchart illustrating an embodiment of a process forstoring information in memory and tracking where information is stored.

FIG. 9 is a flowchart illustrating an embodiment of a process forretrieving information stored in memory sub-allocated to a backup and/orstorage related task.

FIG. 10A is a diagram illustrating an embodiment of a desired piece ofinformation and an additional piece of information that are retrievedfrom secondary memory and placed in a cache.

FIG. 10B is a diagram illustrating an embodiment of a desired piece ofinformation retrieved from a cache.

FIG. 11 is a flowchart illustrating an embodiment of a process forretrieving information, where the information is stored in a cacheand/or an associated memory.

DETAILED DESCRIPTION

The invention can be implemented in numerous ways, including as aprocess, an apparatus, a system, a composition of matter, a computerreadable medium such as a computer readable storage medium or a computernetwork wherein program instructions are sent over optical or electroniccommunication links. In this specification, these implementations, orany other form that the invention may take, may be referred to astechniques. A component such as a processor or a memory described asbeing configured to perform a task includes both a general componentthat is temporarily configured to perform the task at a given time or aspecific component that is manufactured to perform the task. In general,the order of the steps of disclosed processes may be altered within thescope of the invention.

A detailed description of one or more embodiments of the invention isprovided below along with accompanying figures that illustrate theprinciples of the invention. The invention is described in connectionwith such embodiments, but the invention is not limited to anyembodiment. The scope of the invention is limited only by the claims andthe invention encompasses numerous alternatives, modifications andequivalents. Numerous specific details are set forth in the followingdescription in order to provide a thorough understanding of theinvention. These details are provided for the purpose of example and theinvention may be practiced according to the claims without some or allof these specific details. For the purpose of clarity, technicalmaterial that is known in the technical fields related to the inventionhas not been described in detail so that the invention is notunnecessarily obscured.

Using memory is disclosed. In some embodiments, a block of memory isobtained from a memory allocator. A first location in the block ofmemory may be sub-allocated to a first backup and/or restoration relatedtask. For example, some or all of the memory obtained from the memoryallocator is used for the first task. In some embodiments, a backupand/or restoration task is associated with a block based system, asopposed to a file based system. In a block based backup, blocksassociated with files being backed up are written to backup media andblocks associated with a given file may be scattered throughout backupmedia (e.g., magnetic tape media). During a restore, blocks that areassociated with the one or more files being restored are retrieved fromthe backup media. An indication is received that the first location isavailable to be sub-allocated to a subsequent backup and/or restorationrelated task, if any. For example, in some embodiments, a memory onceallocated, e.g., to a backup related process, is reused to perform aseries of backup tasks and is not necessarily released or returned afterit is done being used for an initial task for which it was firstrequested to be allocated. For example, a memory may be used during afirst period of time to store a first set of information (i.e., for afirst task) and may be used during a second period of time to store asecond set of information (i.e., for a second task).

In some embodiments, when retrieving a desired or needed piece ofmetadata from a metadata store, information in addition to the desiredpiece of information is retrieved without first determining whether theadditional information is currently needed. The retrieved information,including the additional information, in some embodiments is stored in acache, for example until it is requested. In some embodiments, when anindication is received that a particular piece of metadata is needed ordesired, the cache is first checked to determine if that piece ofmetadata is stored in the cache. In some embodiments if a piece ofmetadata is stored in the cache, it is retrieved from the cache (e.g.,as opposed to the metadata store).

FIG. 1 is a system diagram illustrating an embodiment of a backupsystem. In the example shown, backup system 100 stores data associatedwith one or more files (or other data objects) to back up those files.In some embodiments, backup server 102 performs backup relatedfunctionality such as managing data backup and managing the retrieval ofstored data during restoration. In some embodiments, backup server 102interacts with a client or other agent running on restoration target 104and/or backup storage device 106 that is configured to communicate withbackup server 102.

During a backup, backup server 102 in some embodiments determinesappropriate data to store and passes this data to backup storage device106 to be stored. In some embodiments, backup server 102 directs aclient or agent to pass data to be saved directly to backup storagedevice 106. In some embodiments, backup server 102 manages theorganization and controls where information is stored on backup storagedevice 106, for example by maintaining a table or list of storedinformation and corresponding physical locations on backup storagedevice 106. During a restore, in some embodiments backup server 102receives, e.g., from restoration target 104, a list of files or otherdata objects to be restored to restoration target 104. To restore thosefiles on restoration target 104, information associated with those filesis retrieved from backup storage device 106 and passed to restorationtarget 104.

Backup storage device 106 includes backup media for storing information.Storage media associated with backup storage device 106 includes, forexample, magnetic tape media, hard disk media, optical storage media,etc. In some embodiments, backup storage device 106 comprises multiplephysical devices that are coupled to each other via a connection ornetwork. In some embodiments, backup storage device 106 is associatedwith multiple restoration targets.

In some embodiments, block based backup is performed by storing onbackup media multiple blocks of data associated with a particular file.For example, typically files stored on restoration target 104 areorganized and accessed using a file system. Each file typically has aname or other identifier, and the files typically are organizedhierarchically into one or more levels of directories. The datacomprising a file is stored typically as a plurality of blocks of dataon physical storage, such as a hard disk. Data is not necessarily storedin (for example) file offset order on physical storage. During a blockbased backup, the blocks comprising a file to be backed up, or in somecases those blocks that have changed since a previous backup, are copiedand stored on backup media, such as backup storage device 106, which maycomprise fixed storage such as one or more hard drives and/or removablemedia such as tape, optical disk storage, etc. In some embodiments,multiple files are backed up and each backed up file is associated withits own group of blocks (i.e., a given block is associated with at mostone file). Blocks are stored on backup storage device 106. During arestore, blocks associated with the file(s) being restored are retrievedfrom backup storage device 106 and are used to restore the file(s). Someblock based backup systems offer advantages or conveniences overnon-block based backup systems (e.g., traditional file based backupsystems). For example, in some block based backup systems only theblocks that have changed since the last backup backed up, a backupstorage device is used more efficiently since smaller units ofinformation are stored, etc. In some embodiments, blocks for aparticular file are not necessarily stored next to each other on backupstorage device 106 and blocks associated with different files may beintermingled. For example, if a file A comprises blocks A1, A2, and A3,and a file B comprises blocks B1 and B2, the blocks may be stored onbackup media in the order A1-B1-A2-A3-B2. Blocks from still other filesmay also be intermingled with the ones in the preceding example, and/orempty blocks may exist where no backup data is currently stored.

Restoration target 104 in the example shown is the device on which oneor more files or other data objects are to be restored using backup datastored on backup storage device 106. It is not necessary for a filebeing restored to have been created and/or stored previously onrestoration target 104. In some embodiments, restoration target 104 isin an initial or empty state and one or more files are created andfilled with information from blocks stored on backup storage device 106,e.g., as a result of having been backed up from a host other thanrestoration target 104. In some embodiments, a file being restored wasoriginally stored on and backed up from restoration target 104 but (forexample) becomes corrupted and is restored using the backup data.

Backup server 102, backup storage device 106, and restoration target 104communicate via network 108. In some embodiments, an optional additionalor separate connection 110 between restoration target 104 and backupstorage device 106, e.g., a direct connection and/or a connection via astorage area network (SAN), is used. Connection 110 is optional and isnot implemented in some embodiments. In some embodiments, informationthat is retrieved from backup storage device 106 is passed torestoration target 104 using connection 110 rather than network 108.Network 108 and connection 110 can be implemented using a variety ofnetworks and connections such as a Storage Area Network (SAN) and SmallComputer System Interface (SCSI). In some embodiments, thenetwork/connection topography and/or the number of components includedin backup system 100 varies from the example shown.

Efficient use of memory during a block based restoration process isdisclosed. Memory is obtained, used, and/or managed in such a way thatoverhead associated with working with memory is reduced. For example,rather than requesting separately for each piece of information to bestored that a location in memory be allocated, e.g., by the operatingsystem and/or a component and/or process associated with the operatingsystem, in some embodiments memory is obtained (i.e., caused to beallocated) and the agent or process that obtained the memory manages useof the memory to perform multiple tasks each of which would otherwisehave required its own memory allocation request. For example, in variousembodiments the agent/process that manages access and/or use ofpreviously allocated memory performs such functions as determining andassigning for use by itself and/or one or more other processes, asrequested and/or required, unused locations in the previously allocatedmemory, recording or otherwise tracking location(s) in memory whereinformation is written to, determining where in memory a given piece ofinformation is stored when that piece of information is desired,removing or otherwise deleting tracking and/or location informationassociated with a given piece of information that is no longer needed orbeing used, etc.

In some embodiments, additional and/or alternative techniques are usedto improve the performance associated with using memory. For example,rather than returning a memory after it is used to store a set ofinformation, in some embodiments a memory is retained and is notnecessarily returned or otherwise released after it is done being usedfor a certain purpose or operation. In some embodiments, some locationor portion of a memory is sub-allocated to a subsequent backup relatedtask (if any) once that portion or location in memory is done being usedfor a prior backup related task. For example, in some embodiments amemory is only released when an overall process is completed (e.g., theoverall process or task of restoring objects to a restoration target iscompleted). In some embodiments, when retrieving from a metadata cacheone or more desired pieces of metadata associated with a set of backupdata, additional pieces of metadata are also retrieved where there is(for example) no determination is performed and/or no indication isreceived regarding whether the additional pieces of information arecurrently needed. These additional pieces of information are stored incache (or other storage that is faster to access compared to themetadata store). If some of metadata stored in cache is subsequentlydesired or needed, it is retrieved from the cache rather than themetadata store.

Some or all of the components in block based backup system 100 may usememory in the manner(s) described above. In some embodiments, backupserver 102 and/or restoration target 104 (or an agent or process runningon such a component) is configured to work with memory in manner toreduce overhead associated with using memory.

FIG. 2A is a diagram illustrating an embodiment of a metadata tableassociated with block based backup. In the example shown, metadata table200 includes four inode entries. An inode is associated with a file,directory, or other object on a file system and includes informationused in restoring a file to a restoration target. As used herein, aninode may be associated with any operating system (e.g., UNIX orMicrosoft Windows operating system) and/or any file system. In someembodiments, an inode is a unique integer identifier that the givenfilename is mapped to, for example internally by a file system. In someembodiments, each file (or other data object) is associated with aparticular inode that has a unique inode number. For example, inodes 1-4are associated with files A-D, respectively. File size (e.g., in bytes),permissions associated with a file (e.g., readable, writeable, etc.),block location (e.g., physical location(s) of associated blocks onbackup media), and file offset (e.g., the offsets in a file that eachblock associated with that file is respectively written to during arestore) are stored in metadata table 200 for each inode. In thisexample, an inode number (e.g., inode 1, inode 2, etc.) associated witha file is used to access or otherwise retrieve information from metadatatable 200 for a given file (i.e., metadata table 200 is organizedaccording to inode number rather than, for example, file name).

Metadata table 200 is updated as appropriate to backup one or morefiles. For example, a new inode entry is created to reflect a new file,or file size is entered or updated to reflect the current file size.During a restore, information stored in metadata table 200 is retrievedand used in restoring a file to a restoration target. For example, torestore a file associated with inode 1, block location(s) are retrievedfrom the entry for inode 1. Blocks at those locations are retrieved(e.g., from backup media associated with a backup storage device) andare used to restore that file.

Metadata table 200 is updated by or in general managed by anyappropriate entity and is stored on any appropriate device. In someembodiments, metadata table 200 is managed by and stored on a backupserver. In some embodiments, metadata table 200 is stored on a backupstorage device.

In some embodiments, information associated with metadata table 200 isstored, managed, and/or accessed in a manner to reduce overheadassociated with using memory. In some embodiments a block of a memory isobtained (e.g., using a single call or procedure). Locations in memoryare sub-allocated for a given restoration task, for example storing filepermissions. An indication is received that the first location isavailable to be sub-allocation for a subsequent backup and/orrestoration task, if any. In some embodiments, information associatedwith metadata table 200 is stored in a metadata store and whenretrieving a piece of needed metadata from the metadata stored (e.g.,file size, permissions, block location or other information associatedwith metadata table 200), additional information is retrieved adjacentin the metadata store to the needed piece of metadata. The retrieved setof metadata (e.g., including the needed and additional pieces ofmetadata) are stored in a cache.

FIG. 2B is a diagram illustrating an embodiment of blocks retrieved froma backup storage device and forwarded to a restoration target. In theexample shown, blocks associated with files A-D are stored on backupmedia associated with backup storage device 250. Blocks associated witha given file are not necessarily stored next to each other. To restoreone or more files, blocks associated with the files being restored areretrieved from backup storage device 250 and are forwarded torestoration target 252. For example, to restore file A 254, blocks A1256 and A2 258 are retrieved from backup storage device 250 andforwarded to restoration target 252. In some embodiments, the physicallocations of the blocks retrieved from backup storage device 250 areobtained from a metadata table. At restoration target 252, blocks areused to restore the desired files. For example, file A 254 is created oropened and data in blocks A1 256 and A2 258 are written to the file.

In some embodiments, certain methods of retrieving or otherwiseaccessing information from metadata table 200 and/or backup storagedevice 250 are faster or otherwise more desirable than other methods.For example, when reading or otherwise retrieving information formultiple inodes from metadata table 200 it is faster in some embodimentsto read them in inode number order. In some embodiments, it is faster toretrieve blocks from backup storage device 250 in block location orderrather than retrieving blocks non-sequentially. In some embodiments,blocks in addition to those that are associated with a file beingrestored are retrieved from backup storage device 250.

FIG. 3 is a flowchart illustrating an embodiment of a process performedby a backup server to restore one or more files on a restoration target.In the example shown, block based backup is performed. In someembodiments, a client or other agent running on a restoration targetand/or a backup storage device perform counterpart processing.

At 300, a list of files to restore is received. In some embodiments, alist of files to restore is received from a restoration target. In someembodiments, in addition to or as an alternative to file name, the listof names includes location with a file system hierarchy, version of thefile to restore, restore settings (e.g., overwrite any existing file orrestore a file while maintaining any existing version), etc.

File names are mapped to inode numbers at 302. In some embodiments, arecord, table, or metadata is used to map file name to inode number. Insome embodiments, such a record of file names and inode numbers ismaintained by a backup server. At 304 inode numbers are mapped toblocks. In some embodiments, mapping is performed using a metadatatable. Using a metadata table, the physical locations of blocksassociated with the files being restored are obtained. In someembodiments, a metadata table is read or otherwise accessed in an orderthat reflects how inodes are stored in a metadata table. In someembodiments, a metadata table is accessed in any order. In someembodiments, only inodes entries of interest are accessed from ametadata table. For example, files corresponding to inode numbers 100,250, 500, 700, and 800 are being restored on a restoration target. Someblock backed backup systems are configured to access a metadata tableonly at the entries that correspond to inode numbers 100, 250, 500, 700,and 800; other entries in a metadata table are unread in systems thatare so configured.

Blocks are retrieved and forwarded to a restoration target at 306. Insome embodiments, additional blocks (e.g., “empty” blocks or blocks thatare associated with files that are not being restored) are retrievedand/or forwarded at 306. In some embodiments, it is faster to retrieveneeded blocks and some additional blocks (e.g., and discard thoseadditional blocks later) rather than retrieve only blocks that areneeded.

In some embodiments, an agent or process running on a backup server ortarget restore host obtains, stores information in, retrievesinformation from, and/or manages memory in an efficient or fastermanner. For example, some backup servers are configured to obtain ablock of memory from a memory allocator and sub-allocate a location orportion of the block of memory for a backup and/or restoration relatedtask. In some embodiments, that location or portion of the block ofmemory is subsequently allocated (e.g., by the backup server) foranother task once the first task is completed. In some embodiments, anagent or process running on a backup server stores metadata in ametadata store. An indication is received that a piece of metadata isrequired. In addition to the needed piece of metadata, other metadatathat is not currently needed or desired is retrieved from the metadatastore. The retrieved information is stored in a cache where (forexample) some metadata may be retrieved from the cache should asubsequent indication be received and that metadata be stored in thecache at that time.

FIG. 4 is a flowchart illustrating an embodiment of a process performedby a client or agent running on a restoration target to restore one ormore files on the restoration target. In the example shown, a client oragent running on a restoration target is configured to interact with orotherwise communicate with a counterpart process running on a backupserver and/or a backup storage device to restore one or more files on arestoration target.

At 400, an indication of files to be restored is received. In someembodiments, a user interacts with a restoration related interface toinitiate a restore, select the files to be restored, select a version ofa file to be restored, set restoration settings/parameters, designaterestoration target(s), etc. In some applications, files being restoredon a restoration target do not necessarily exist on a restoration target(e.g., a restoration target is an initial or “empty” state) and/or somefiles that exist on a restoration target are not being restored.

A list of files to be restored is sent to a backup server at 402. Insome embodiments, an unsorted or otherwise unordered list is sent to abackup server. In some embodiments, a sorted list is sent. At 404,blocks retrieved from backup media are received and processed to restorefiles. In some embodiments, a contiguous group of blocks that includesat least one block that is not associated with a file to be restored isreceived. In some embodiments, all received blocks are associated with afile to be restored. To restore a file, in some embodiments a filecorresponding to a block being processed is opened and data included inthe block is written to the file at the corresponding file offsetdetermined by the metadata table. In some embodiments, multiple blocksare needed to restore a particular file.

In some embodiments, the processing performed on a restoration targetvaries from the example described herein. For example, in someembodiments, a user or process interacts with a backup server to specifythe files to be restored and a list of files to be restored is not sentfrom a restoration target.

In some embodiments, an agent or process running on a restoration targetobtains, uses, and/or manages memory in an efficient manner. Forexample, in some embodiments, a process or agent running on arestoration target obtains memory from a memory allocator and managessub-allocation of the block of memory for various backup and/orrestoration related tasks. In some embodiments, once a location orportion of the block is done being used for one task, that location orportion is used for a subsequent task should a subsequent task exist.

FIG. 5A is a diagram illustrating an embodiment of a memory that isobtained, written to, read from, or otherwise used in an efficientmanner. In the example shown, memory 500 is allocated by an entity thathas control over and/or management of memory allocation, such as anoperating system or an environment or platform that a program or agentis running on. In various embodiments, the entity responsible forallocating memory varies (e.g., based on the particular embodiment) andfor convenience is referred to as a memory allocator. In someembodiments, a single memory allocation call, request, procedure, orinvocation (e.g., “malloc”) is used to obtain memory 500. An appropriatesize or amount of memory is determined in some embodiments and is passedto a memory allocator with a memory allocation call; in some embodimentsa default or defined size or amount of memory is requested.

Various pieces of information (e.g., data 1-3) are stored in memory 500.Rather than invoking separate memory allocation calls for each piece ofinformation, memory 500 is obtained in a single memory allocation call.In some embodiments, the memory that is returned in response to a memoryallocation call is a contiguous block of memory in, for example, virtualor physical memory.

In some systems, performing a (e.g., single) memory allocation call ismore efficient than performing multiple memory allocation calls eachtime, for example, a backup and/or restoration related task needs to beperformed. For example, in some systems allocating a large amount ofmemory takes substantially the same amount of time as allocating asmaller amount of memory because of overhead. Another advantage in somesystems is that the memory allocated is associated with a single, largersegment of data that is fetched or loaded when reading or writing to anyportion of the larger data segment. One example of such a memory systemis a page based system. If a page based system is used, memory 500 ispotentially allocated from a single page and is not spread over multiplepages. If memory is allocated from a single page, a page miss is avoidedwhen reading from and/or writing to different offsets of memory 500.Page misses result in an increased amount of time to read from or writeto a given offset in memory 500. As an example of a page miss, offset 0is accessed and is associated with a first page. Offset 7 is associatedwith another page and is accessed after offset 0; the new pageassociated with offset 7 must be fetched and/or loaded which requires anincreased amount of time to access offset 7. Similar advantages inavoiding an increased access time can exist for other memory systemsthat do not use pages.

Since a single memory allocation call is performed and sub-allocation ofthe block of memory is managed by the entity that obtained the block ofmemory, sub-allocation of memory 500 and the locations in memory 500where particular pieces of information are stored is managed and/ortracked. In this example, memory 500 is partitioned or otherwisesegmented into smaller units at certain offsets, and each piece ofinformation is written to an offset and uses one or more units (e.g.,byte, word, double word, etc.) within memory 500. In this example, data1 is stored at offset 0 and is 1 unit long, data 2 is stored at offset 1and is 2 units long, and data 3 is stored at offset 4 and is 1 unitlong. At offset 3 there is an empty unit that separates data 2 and data3. Information is stored at any appropriate offset in memory 500. Ifadditional pieces of information are received, they can be written tounused offsets within memory 500. In some embodiments, data 1-3 areassociated with a particular backup and/or restoration task and memory500 is sub-allocated within a larger block of memory. In someembodiments, there are multiple backup and/or restoration related tasksthat are allocated portions of memory (e.g., each is allocation alocation or portion of memory of its own similar to memory 500). In someembodiments, the tasks are independent, and one task may end beforeanother task, etc. In some embodiments, the amount of data associatedwith a particular task varies over time.

In various embodiments, memory 500 is obtained at various times. In someembodiments, memory 500 is obtained before data 1-3 is obtained. Adefault size or amount of data is obtained from a memory allocator insome embodiments. When data 1-3 is obtained, the information is writtento the already obtained memory 500. In some embodiments, data 1-3 isobtained, memory 500 is obtained from a memory allocator, and data 1-3is written to memory 500. In some embodiments, it is anticipated thatadditional information will be stored in memory 500 and the amount ofmemory obtained is sufficient to hold data 1-3 and additional pieces ofinformation. For example, the size of memory 500 in this example issufficient to store some additional information.

In some embodiments, memory 500 is reused. That is, after memory 500 isno longer being used to store a certain type of information or for acertain task, memory 500 in some embodiments is not released orotherwise returned (e.g., to a memory allocator). Memory 500 and/ortracking of where information is stored on memory 500 is reset,initialized, or cleared as appropriate. For example, a table may be usedto track the offsets at which data 1-3 are stored. This table may bereset to indicate that all offsets are empty so that memory 500 can beused to store another type of information and/or be used for anotherpurpose. Should there be a subsequent task that needs memory, memory 500is some embodiments sub-allocated to a second backup and/or storagerelated task once a first backup and/or storage related task iscompleted. In some embodiments, memory 500 is only released or returnedto a memory allocator when an overall process is complete (e.g., when arestoration or a backup process is complete and there would be nosubsequent tasks).

FIG. 5B is a diagram illustrating an embodiment of a tracking table usedto track usage of a block of memory. In the example shown, trackingtable 502 is used to track or otherwise record where information isstored in memory 500 (e.g., for a particular task for which memory 500is sub-allocated from a larger block of memory). For each piece ofinformation stored in memory 500, the corresponding offset and lengthare recorded. The entry for data 1 indicates that it is stored at offset0 and has a length of 1 unit. Similarly, entries for data 2 and 3indicate that they are stored at offsets 1 and 4, respectively, and are2 and 1 unit(s) long, respectively. In some embodiments, an identifieror reference is assigned to each piece of information and the identifieris stored in the first column of tracking table 502. To obtain a pieceof information from memory 500, the corresponding identifier orreference is obtained and tracking table 502 is referenced to determinethe proper offset and number of units associated with that piece ofinformation. Memory 500 is then read or accessed beginning at thatoffset for those number of units.

In some embodiments, tracking usage of memory is implementeddifferently. For example, information may be stored in a variety of datastructures. Tracking table 502 in some embodiments is implemented as afile, a database, etc. In some embodiments, tracking table 502 includesentries for each offset. For example, in some embodiments, trackingtable 502 has 8 entries. Entries for offsets 0 and 4 include informationindicating that data 1 and 3 are stored at those offsets, respectively.Entries for offsets 1 and 2 include information indicating that data 2is stored at those offsets. If needed, additional fields are used toindicate, for example, that the first portion of data 2 is stored atoffset 1 and the second portion is stored at offset 2. In someembodiments, a piece of data is stored contiguously in memory and noadditional fields are needed to specify which portion of data 2 isstored at which offset. Entries for offsets 3 and 5-7 indicate that theyare empty.

In some cases, memory 500 is being used for a particular backup and/orrestoration related task and fills up. In some embodiments memory 500 ismaintained or kept for use by the task and additional memory issub-allocated to augment or supplement memory 500. Tracking table 502 ismodified as appropriate to reflect a additional memory. In someembodiments, a new location or portion of a block of memory that islarger than memory 500 is sub-allocated for use by a task if memory 500should become full and memory 500 released (e.g., to be sub-allocatedfor use by another task).

In various embodiments, memory 500 and tracking table 502 are on variouscomponents of a block based backup system. In some embodiments, memory500 and tracking table 502 are kept on the same physical component. Insome embodiments, memory 500 and tracking table 502 are kept ondifferent physical components.

FIG. 6A is a flowchart illustrating an embodiment of a process forobtaining memory from a memory allocator and sub-allocating a locationin the memory to a backup and/or restoration task. In the example shown,memory is obtained from a memory allocator by performing a memoryallocation call. A counterpart process associated with retrievinginformation stored in memory (e.g., in response to a request orindication for desired information) may be running independently of theillustrated process.

At 600, a block of memory is obtained from a memory allocator. In someembodiments, an amount of information to obtain is determined. In someembodiments, a default or defined amount of memory is obtained. In someembodiments, memory is obtained from a memory allocator using a singlememory allocation call (e.g., a malloc call).

A location in a block of memory is sub-allocated for a backup and/orrestoration related task at 602. For example, a chunk of the memoryobtained from the memory allocator is allocated for use by a particulartask. In some embodiments, one or more non-overlapping locations orportions of a block of memory obtained from a memory allocator aresub-allocated for various tasks. For example, a first location issub-allocated for use by a first task, a second location issub-allocated for use by a second task. In some embodiments, a trackingtable is associated with a given location sub-allocated for a particulartask. A tracking table may be used to store memory offsets and sizes forinformation stored in a particular sub-allocated memory. Information tobe stored may be received at various times from a given backup and/orrestoration task. In some embodiments, all information to be stored isobtained at one time. In some embodiments, information to be stored isobtained over a period of time.

At 604, memory is released, if needed. In some embodiments, anindication is received that a location in a block of memory that issub-allocated for a certain task is available to be sub-allocated toanother task (if any). For example, the indication may be that the firsttask is done using the sub-allocated location in memory. In some cases,the indication is that the first task is completed. If such anindication is received, it is helpful in some systems to release orotherwise free a block of memory that is obtained from a memoryallocator. An appropriate procedure or call may be used to releasememory. In some embodiments, no call is performed to release memory. Forexample, some automatic memory management systems perform garbagecollection to automatically reclaim a block of memory that is no longerbeing used. In such systems it is not necessary to explicitly releasememory by performing a memory release call.

FIG. 6B is a flowchart illustrating an embodiment of a process forobtaining memory from a memory allocator and sub-allocating a locationin the memory to a subsequent backup and/or restoration task, if any,once the location become available. In the example shown, the process issimilar to that of FIG. 6A but a location or portion of memory that issub-allocated for a first task is reused for a second task and is notnecessarily released after being sub-allocated to the first task. Insome embodiments, there may be some period of time betweensub-allocating a location in memory to a first task and sub-allocatingthe same location to second task. In some embodiments (e.g., the exampleillustrated in FIG. 6A), memory is used or otherwise associated with asingle task and is then released.

At 600, a block of memory is obtained from memory allocator. A locationin a block of memory is sub-allocated for a backup and/or restorationrelated task at 602. At 606, an indication is received that a locationis available to be sub-allocated to a subsequent backup and/orrestoration related task, if any. For example, the task that has beensub-allocated a location or portion of a block of memory may indicatewhen it no longer needs the memory, the information stored in memory,and/or the task is completed. In some embodiments, multiple locations inmemory are sub-allocated for various tasks and an indication is receivedfor one location in particular that is available to be sub-allocated toa subsequent task.

At 608 it is decided if it is done. In some embodiments, this occurswhen an overall process is done. For example, in some block based backupsystems, memory is used during restoration to store metadata associatedwith one or more files or other data objects being restored. When all ofthe files are restored to a restoration target, the overall process iscomplete.

If it is done, memory is released, if needed at 604. Otherwise, trackingassociated with a previous backup and/or restoration task is reset at610. For example, a tracking table is reset or otherwise initializedand/or memory associated with the tracking table is erased. The state ofa reset or initialized tracking table corresponds to or otherwiseindicates that an associated memory is completely free or unused. Insome embodiments, the memory itself is erased or otherwise set to aninitial or default state. A location in a block of memory issub-allocated for a subsequent backup and/or restoration related task at602. For example, a memory may be reused to store a different set ofinformation associated with a subsequent task.

FIG. 7 is a flowchart illustrating an embodiment of a process forobtaining memory. In the example shown, the illustrated process is usedin some embodiments to obtain memory at 600. In some embodiments, analternative process is used. For example, in some embodiments, a defaultor defined amount of memory is obtained rather than determining anamount.

An amount of memory to be obtained is determined at 700. In someembodiments, some or all of the information to be stored is alreadyobtained and the size of each piece of information and/or the number ofpieces of information can be used to determine an appropriate amount ofinformation to obtain. In some embodiments, the information to be storedis not obtained prior to determining an amount of information to obtain,but parameters or characteristics describing or otherwise associatedwith the information to be stored are available and are used indetermining an amount of memory to obtain. In some embodiments, it isassumed or known that additional pieces of information will be stored inmemory, and the amount of memory determined at 700 accounts for anyanticipated or known amount of information to be stored in the future.

At 702, memory is obtained from a memory allocator. In some embodiments,a memory allocation call is performed and the amount of memorydetermined at 700 is passed to a memory allocator with a memoryallocation call.

Tracking of usage of memory is initialized at 704. In some embodiments,tracking includes tracking which locations or portions of a block ofmemory are sub-allocated for particular tasks. In some embodiments, atracking table, database, or file is used to track where a piece ofinformation is stored in memory. If needed, a tracking table ispopulated or filled with values indicating that an associated memory isempty (i.e., contains no information). In some embodiments, multipletracking tables are used (e.g., there is a tracking table for eachlocation in a block of memory that is sub-allocated to a particularbackup/restoration task).

FIG. 8 is a flowchart illustrating an embodiment of a process forstoring information in memory and tracking where information is stored.In the example shown, the process is used in some embodiments to storeand track information at 602.

At 800, a piece of information to be stored in memory is obtained. Inthis example, a single piece of information is stored and tracked. Insome embodiments, multiple pieces of information are simultaneouslyprocessed and the illustrated process is modified accordingly.

A location in memory to store a piece of information is determined at802. For example, a tracking table may be referenced. Using such atracking table or other data structure, empty offsets or locations inmemory are determined. In some embodiments, a piece of information isplaced contiguously in (e.g., virtual or physical) memory. In systemsthat are so configured, a location that is sufficient to hold an entirepiece of information is determined. For example, offset 3 in FIG. 5Awould not be selected to store a piece of information 2 units long sincethere is only 1 unit of memory available. A location that comprises ofoffsets 5-6 or offsets 6-7 would be selected instead. In someembodiments, a piece of information is not necessarily storedcontiguously in memory. As described, in various embodiments informationis stored using various rules and an appropriate location determined at802 is based on those rules. In some embodiments, related pieces ofinformation (e.g., associated with the same file being restored, sametype of information, etc.) are stored next to or relatively near eachother in memory and an appropriate location is determined based on thatrule and any other rules.

At 804, a piece of information is written to the location in memory. Anappropriate command or call may be used to perform a write. At 806, atable is updated to reflect storing a piece of information at thatlocation. For example, a new entry that includes an identifierassociated with the piece of information, an offset, and a size is addedto a tracking table.

At 808, it is decided if a current usage done. In various embodiments, amemory can be reused for other purposes or another set of information orbe released. A decision outside the scope of the illustrated process maydetermine whether or not to reuse a memory. In some embodiments, anindication is received indicating that a current usage is done. If acurrent usage is not done, a piece of information is obtained at 800.The illustrated process may be repeated as many times as needed asinformation to be stored is obtained over a period of time.

FIG. 9 is a flowchart illustrating an embodiment of a process forretrieving information stored in memory sub-allocated to a backup and/orstorage related task. In the example shown, a block of memory isobtained using a single memory allocation call or procedure, and someportion of that block of memory is sub-allocated to a task. Multiplepieces of information associated with a task are stored in thesub-allocated memory and their locations in memory are tracked. Anentity or other source that stored information in a memory may at somepoint desire some or all of the stored information. The illustratedprocess may be used to retrieve information stored in a sub-allocatedmemory.

At 900, an indication that one or more pieces of information stored insub-allocated memory is/are desired is received. For example, anindication may include references or identifiers associated with thedesired piece(s) of information. At 902, location(s) in sub-allocatedmemory where desired piece(s) of information are stored is determined.For example, a tracking table is used in some embodiments to storememory offsets and sizes of information stored in memory sub-allocatedfor a certain purposed. A tracking table or other data structure may bereferenced to determine where each desired piece of information isstored. Desired piece(s) of information are retrieved and forwarded froma sub-allocated memory at 904.

In some embodiments, the illustrated process operates or functionsindependently or in parallel to a process to store information in amemory sub-allocated to a task from a block of memory. This may bedesirable in some systems where reading and writing to a sub-allocatedmemory are intermingled and waiting is undesirable. This may prevent oneprocess (e.g., reading) from waiting while the other process (e.g.,writing) is being serviced. Such a system may be conceptualized as a2-port system, where one port is a read port and one port is a writeport. In some embodiments, race conditions between intermingled readingand writing is a concern. For example, if a read and a write to the samepiece of information are performed at substantially the same time, thedata returned to the read procedure may be the old value or new value,depending upon which procedure occurred first. In such systems, aconceptual 1-port system where reading and writing are serviced by thesame entity may be desirable to avoid race conditions.

FIG. 10A is a diagram illustrating an embodiment of a desired piece ofinformation and an additional piece of information that are retrievedfrom secondary memory and placed in a cache. In the example shown, data1 is desired or needed (e.g., by an entity that stored data 1-4 insecondary memory 1000). In some embodiments, an indication is receivedthat data 1 is desired or is needed. Data 2 is not requested orotherwise needed at this time. For example, an indication (if received)does not indicate that data 2 is needed at this time and/or it is notfirst determined that data 2 is needed before data is retrieved fromsecondary memory 1000.

Data 1 and 2 are stored on secondary memory 1000. Data 1 and 2 areretrieved from secondary memory 1000 and are stored on cache 1002. Insome embodiments, secondary memory 1000 is a magnetic tape, hard drive,optical disk, etc. A cache in this context is defined to be some storagethat is faster to read from or otherwise access compared to a secondarymemory (e.g., magnetic tape or hard disk). In some embodiments, cache1002 is a physical memory, processor cache, and/or a high performancememory. Data 1 is forwarded to the appropriate entity that requested orotherwise desired data 1. For example, metadata or other data that isstored on a secondary medium such as a hard drive or magnetic tape isretrieved and stored on, for example, physical memory so that a queryfor a next record will not require the access to the secondary medium,but is retrieved from physical memory.

In various embodiments, the additional data (e.g., data 2) is selectedusing various parameters and/or selection criteria. In some embodiments,a certain number of additional pieces of information are retrieved inaddition to the desired piece(s) of information. In this example, oneadditional piece of information is retrieved from secondary memory 1000;in some embodiments, two or more additional pieces of information areretrieved. In some embodiments, the additional information retrieved isselected based on a piece of information's placement or location insecondary memory 1000 with respect to a desired piece of information.For example, in some embodiments, the additional piece(s) of informationthat is/are retrieved from secondary memory 1000 and stored in cache1002 precedes, follows, or is otherwise adjacent to a desired piece ofinformation in virtual or physical memory. In some embodiments, piecesof information have relationships to other pieces of information. Forexample, a given desired piece of information may be associated with aparticular file that is being restored. In some embodiments, theadditional piece(s) of information is/are also associated with thatfile.

FIG. 10B is a diagram illustrating an embodiment of a desired piece ofinformation retrieved from a cache. In the example shown, some timeafter data 1 and 2 are stored in cache 1002, data 2 is needed. Forexample, an indication may be received that data 2 is needed. In someembodiments, it is first determined whether data 2 is stored in cache1002. Since data 2 is stared in cache 1002, data 2 is read from orotherwise obtained from cache 1002 and is forwarded to an appropriateentity without accessing secondary memory 1000. Accessing cache 1002 isfaster than accessing secondary memory 1000 and thus retrieving data 2from cache 1002 is faster than retrieving data 2 from secondary memory1000. Caching information as shown may be transparent. For example, theentity that requests or otherwise needs data 1 and 2 may be unaware ofthe existence or usage of cache 1002.

In some embodiments, cached information is stored and/or manageddifferently than the example shown herein. For example, in someapplications a given piece of information will only be requested once.In some embodiments, a needed or requested piece of information (e.g.,data 1) is obtained from secondary memory 1000 but is not stored incache 1002. For example, only data 2 is stored in cache 1002. This mayleave more room in cache 1002 for other information to be stored. Insome embodiments, data is removed from a cache once it is retrieved froma cache. For example, after retrieving data 2 from cache 1002 in theexample of FIG. 10B, data 2 may be removed from cache 1002.

In some embodiments, cached information is overwritten by otherinformation. For example, cache 1002 is typically smaller than secondarymemory 1000 and may become full. In some embodiments, some informationstored in cache 1002 is selected to be overwritten and one or moredecision parameters are used to make the selection. For example, somesystems are configured to select the oldest piece(s) of information in acache to be overwritten should a cache become full. Other criteriabesides age may be used.

FIG. 11 is a flowchart illustrating an embodiment of a process forretrieving information, where the information is stored in a cacheand/or an associated memory. In the example shown, a secondary memoryhas associated with it a cache that is faster to access compared to thecorresponding secondary memory. A subset of information stored insecondary memory is stored in cache. The particular subset ofinformation stored in a cache may vary over time, for example, as thecache becomes full and older information is overwritten in the cache oras cached information is needed, obtained from the cache, forwarded toan appropriate entity, and removed from the cache. In some embodiments,the illustrated process is repeated, for example as pieces ofinformation are needed or requested over a period of time.

At 1100, an indication is received, identifying one or more pieces ofdesired information. In some embodiments, the desired informationincludes metadata records associated with a block based backup and/orrestoration. It is decided at 1102 whether it is stored in a cache.Referring to the example of FIG. 10B, an indication may be received thatdata 2 is desired and it is determined if data 2 is stored in cache1002.

If it is stored in a cache, at 1104 desired piece(s) of information areobtained from a cache and forwarded. In the example of FIG. 10B, data 2is the desired information retrieved from cache 1002. In someembodiments, the desired information stored in a cache is deleted orotherwise removed from a cache after it is retrieved and forwarded at1104.

If it is not stored in a cache, information to retrieve from a secondarymemory is determined where the information includes desired piece(s) ofinformation and one or more pieces of additional information at 1106.The additional pieces of information are not requested or otherwiseneeded at this point. In various embodiments, various parameters (e.g.,a number of additional pieces of information to retrieve) and/ordecision criteria (e.g., selecting additional pieces of information isbased on where information is stored in memory, based on a relationshipwith a desired piece of information, etc.) are used to select the one ormore pieces of additional information.

At 1108, information is retrieved from a secondary memory. In theexample of FIG. 10A, the desired piece of information (data 1) and theadditional piece of information (data 2) are retrieved from secondarymemory 1000. At 1110, desired piece(s) of information are forwarded toan appropriate entity. For example, the desired piece(s) of informationare forwarded to the entity that was the source or originator of theindication received at 1100. At 1112, the additional piece(s) ofinformation at least are stored in cache. In some embodiments only theadditional information is stored in a cache. In some embodiments, someor all of the desired information is stored in cache.

In some embodiments, if a cache is full, one or more cached items areselected to be overwritten. In some embodiments, no information isdeleted or overwritten in a full cache (i.e., no new information isadded to a cache once it is full). In some embodiments, minimum and/ormaximum thresholds are used to determine how long to store informationin a cache. For example, some systems are configured to store an item ofcontent for a minimum amount of time and/or remove it (or make iteligible to be removed should something need to be removed) after amaximum amount of time.

Although the foregoing embodiments have been described in some detailfor purposes of clarity of understanding, the invention is not limitedto the details provided. There are many alternative ways of implementingthe invention. The disclosed embodiments are illustrative and notrestrictive.

What is claimed is:
 1. A method of using memory, comprising: receivingat a processor an indication of a restoration of a block-based backup ofa first file; mapping the first file to a first inode number; receivingat the processor an indication that a first piece of metadata isrequired during the restoration, wherein the first piece of metadata isa first row of a metadata table comprising a block location for thefirst inode number; using the processor to retrieve from a metadatastore a set of metadata that includes the first piece of metadata andone or more additional pieces of metadata included in the metadata storein an adjacent location that is adjacent in inode number order to thefirst inode number, without first determining whether the one or moreadditional pieces of metadata are currently required; forwarding thefirst piece of metadata to an appropriate entity; and storing theadditional pieces of metadata in a cache.
 2. A method as recited inclaim 1 further comprising: receiving an indication that a second pieceof metadata is required; and checking the cache to determine if thesecond piece of metadata is available in the cache.
 3. A method asrecited in claim 2, wherein receiving an indication that a second pieceof metadata is required includes: mapping a name of a second file to berestored to a second inode number; and mapping the second inode numberto one or more locations at which one or more blocks containing contentof the file to be restored is located on backup storage media.
 4. Amethod as recited in claim 1 further comprising: receiving an indicationthat a second piece of metadata is required; checking the cache todetermine if the second piece of metadata is available in the cache; andretrieving the second piece of metadata from the cache if it isdetermined that the second piece of metadata is available in the cache.5. A method as recited in claim 1 further comprising: determining ifusage of the first piece of metadata is done; and in the event usage isdone, removing the first piece of metadata from the cache.
 6. A methodas recited in claim 1 further comprising selecting a piece of metadatato be removed from the cache in the event the cache becomes full.
 7. Asystem for using memory, comprising: a processor; and a memory coupledwith the processor, wherein the memory is configured to provide theprocessor with instructions which when executed cause the processor to:receive an indication of a restoration of a block-based backup of afirst file; map the first file to a first inode number; receive anindication that a first piece of metadata is required during therestoration, wherein the first piece of metadata is a first row of ametadata table comprising a block location for the first inode number;retrieve from a metadata store a set of metadata that includes the firstpiece of metadata and one or more additional pieces of metadata includedin the metadata store in an adjacent location that is adjacent in inodenumber order to the first inode number, without first determiningwhether the one or more additional pieces of metadata are currentlyrequired; forward the first piece of metadata to an appropriate entity;and store the additional pieces of metadata in a cache.
 8. A system asrecited in claim 7, wherein the memory is further configured to providethe processor with further instructions to: receive an indication that asecond piece of metadata is required; and check the cache to determineif the second piece of metadata is available in the cache.
 9. A systemas recited in claim 8, wherein receiving an indication that a secondpiece of metadata is required includes: mapping a name of a second fileto be restored to a second inode number; and mapping the second inodenumber to one or more locations at which one or more blocks containingcontent of the file to be restored is located on backup storage media.10. A system as recited in claim 7, wherein the memory is furtherconfigured to provide the processor with further instructions to:receive an indication that a second piece of metadata is required; checkthe cache to determine if the second piece of metadata is available inthe cache; and retrieve the second piece of metadata from the cache ifit is determined that the second piece of metadata is available in thecache.
 11. A system as recited in claim 7, wherein the memory is furtherconfigured to provide the processor with further instructions to:determine if usage of the first piece of metadata is done; and in theevent usage is done, remove the first piece of metadata from the cache.12. A system as recited in claim 7, wherein the memory is furtherconfigured to provide the processor with further instructions to selecta piece of metadata to be removed from the cache in the event the cachebecomes full.
 13. A computer program product for using memory, thecomputer program product being embodied in a non-transitory computerreadable storage medium and comprising computer instructions for:receiving an indication of a restoration of a block-based backup of afirst file; mapping the first file to a first inode number; receiving anindication that a first piece of metadata is required during therestoration, wherein the first piece of metadata is a first row of ametadata table comprising a block location for the first inode number;retrieving from a metadata store a set of metadata that includes thefirst piece of metadata and one or more additional pieces of metadataincluded in the metadata store in an adjacent location that is adjacentin inode number order to the first inode number, without firstdetermining whether the one or more additional pieces of metadata arecurrently required; forwarding the first piece of metadata to anappropriate entity; and storing the additional pieces of metadata in acache.
 14. A computer program product as recited in claim 13 furthercomprising computer instructions for: receiving an indication that asecond piece of metadata is required; and checking the cache todetermine if the second piece of metadata is available in the cache. 15.A computer program product as recited in claim 14, wherein receiving anindication that a second piece of metadata is required includes: mappinga name of a second file to be restored to a second inode number; andmapping the second inode number to one or more locations at which one ormore blocks containing content of the file to be restored is located onbackup storage media.
 16. A computer program product as recited in claim13 further comprising computer instructions for: receiving an indicationthat a second piece of metadata is required; checking the cache todetermine if the second piece of metadata is available in the cache; andretrieving the second piece of metadata from the cache if it isdetermined that the second piece of metadata is available in the cache.17. A computer program product as recited in claim 13 further comprisingcomputer instructions for: determining if usage of the first piece ofmetadata is done; and in the event usage is done, removing the firstpiece of metadata from the cache.
 18. A computer program product asrecited in claim 13 further comprising computer instructions forselecting a piece of metadata to be removed from the cache in the eventthe cache becomes full.